home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / bit / src / bit.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  6KB  |  172 lines

  1. /*
  2.  * $Id: bit.h,v 0.91 1994/02/20 00:53:33 zhao Pre-Release $
  3.  *
  4.  *. This file is part of BIT shareware package. After the two weeks of
  5.  *  free evaluation period, you are encouraged (required) to register
  6.  *  your copy for a small registration fee, which is $35 for personal use
  7.  *  and $50 for commercial, government and institutional use.
  8.  *
  9.  *  Copyright(c) 1993, 1994 by T.C. Zhao.
  10.  *  All rights reserved.
  11.  *
  12.  *  Permission to use, copy, and distribute this software in its entirety
  13.  *  for non-commercial purposes is hereby granted, provided that the
  14.  *  above shareware and copyright notices and this permission notice
  15.  *  appear in all copies and their documentation.
  16.  *
  17.  *  This software may be modified for your own use, but modified versions
  18.  *  may not be distributed without prior consent of the author.
  19.  *
  20.  *  This software is provided "as is" without expressed or implied
  21.  *  warranty of any kind.
  22.  *
  23.  *.
  24.  *
  25.  * includes, limits, defines, and macros
  26.  */
  27. #ifndef BIT_H_
  28. #define BIT_H_
  29.  
  30. #include <stdio.h>
  31. #include <string.h>
  32. #include <sys/types.h>
  33. #include <sys/stat.h>
  34. #include <limits.h>
  35. #include "unistd.h"
  36. #include "gl/gl.h"
  37. #include "gl/device.h"
  38. #include "utype.h"
  39. #include "ulib.h"
  40.  
  41. /***************************************************************
  42.  * Some limits
  43.  ***************************************************************/
  44.  
  45. #ifndef PATH_MAX
  46. #define MAXDLEN    1024        /* directory name length         */
  47. #else
  48. #define MAXDLEN    PATH_MAX    /* max directory name length     */
  49. #endif
  50.  
  51. #define MAXSIGL     12        /* max signature length          */
  52. #define MAXISIG      4        /* max sig. one image can have   */
  53. #define MAXINFO     32        /* max misc. info length         */
  54. #define MAXFLEN     128        /* file name without directory   */
  55.  
  56. #ifndef MAXMEMK
  57. #define MAXMEMK     3000000L    /* max mem for extra copy mem    */
  58. #endif
  59.  
  60. /*****************************************************************
  61.  * vital function prototypes
  62.  *****************************************************************/
  63.  
  64. typedef struct tc_image *IPTR;
  65. typedef int (*I_IO) (IPTR);    /* get info, load, dump */
  66. typedef void (*I_disp) (IPTR, int, int);    /* display image        */
  67. typedef void (*I_sp) (IPTR);    /* special              */
  68. typedef const char *(*I_wdef) (const IPTR);    /* show dump parameter  */
  69. typedef int (*I_next) (IPTR, int);    /* get next image */
  70.  
  71. /****************************************************************
  72.  * image structures
  73.  ****************************************************************/
  74.  
  75. /*
  76.  * important to use unsigned char for signatures. Also the
  77.  * length is necessary because of non-ascii signatures
  78.  */
  79.  
  80. typedef struct
  81.   {
  82.       int len;            /* signature length     */
  83.       const unsigned char *sig;    /* the signature itself */
  84.   }
  85. SIG;
  86.  
  87. /*
  88.  * structure that completely specifies raster identification and its IO
  89.  * operations. If ncols is negative, the colormap may have arbitrary no. of
  90.  * entries in it.  Of course, in reality, it can't have more than 16bits or
  91.  * whatever the ci_t type can hold, also subject to limits set by
  92.  * CMAPBITS.
  93.  */
  94.  
  95. typedef struct
  96.   {
  97.       IMG_TYPE type;        /* image type, RGB or cmap */
  98.       int ncols;        /* max. no colors for cmap */
  99.       SIG sig[MAXISIG];        /* signatures              */
  100.       const char *info;        /* Full description        */
  101.       const char *key;        /* A short description     */
  102.       const char *ext;        /* image file extensions   */
  103.       I_IO desc;        /* get image descriptions  */
  104.       I_IO load;        /* read it                 */
  105.       I_IO dump;        /* write it                */
  106.       I_next inext;        /* get next image          */
  107.       I_wdef wdef;        /* get the write settings  */
  108.       I_IO dumpi;        /* set parameters          */
  109.       I_disp display;        /* display it              */
  110.       I_sp special;        /* special stuff           */
  111.       int t2b;            /* raster direction        */
  112.       int textsgf;        /* if capable of text &sgf */
  113.   }
  114. IMG_IO;
  115.  
  116. #define TC_FL MAXFLEN
  117. /*
  118.  * Structure that holds the current image, including screen locations and
  119.  * other misc. info.
  120.  */
  121. typedef struct tc_image
  122.   {
  123.       IMG_TYPE type;        /* RGB or CMAP                 */
  124.       IMG_IO *io;        /* handles to IO routines      */
  125.       const char *key, *info;    /* same as in io               */
  126.       void *mraster;        /* virtual framebuffer         */
  127.       void *raster;        /* raster stream               */
  128.       FILE *fp;            /* current stream              */
  129.       pc_t **pc[3];        /* the RGB matrix              */
  130.       int w, h;            /* dimension of the image      */
  131.       int colors;        /* no. of colors, 0 for RGB    */
  132.       unsigned long size;    /* raster size in bytes        */
  133.       CMPTR cmap;        /* colormaps if cmap           */
  134.       int xi, yi;        /* image's screen position     */
  135.       int xf, yf;        /* image's screen position     */
  136.       char *comm;        /* comments                    */
  137.       int esize;        /* pixel size                  */
  138.       int xoff1;        /* horizontal offscreen        */
  139.       int xoff2;        /* horizontal offscreen        */
  140.       int yoff1;        /* vertical invisible part     */
  141.       int yoff2;        /* vertical invisible part     */
  142.       int lsx, lsy;        /* logical screens (unused)    */
  143.       int t2b;            /* raster direction            */
  144.       int interlace;        /* interlace                   */
  145.       int ok;            /* signals raster ok           */
  146.       int aspect;        /* aspect ratio X 1000         */
  147.       int gamma;        /* gamma  X 100 (unused)       */
  148.       int more;            /* number of images            */
  149.       char ifile[TC_FL];    /* input filename              */
  150.       char ofile[TC_FL];    /* output filename             */
  151.       char misc[MAXINFO];    /* other info                  */
  152.   }
  153. TC_IMAGE;
  154.  
  155. /* functions to handle extern window manager redraw events */
  156. typedef int (*WMhandler) (IPTR, int);
  157.  
  158. /* functions to handle redraw of other windows, MultiWindows */
  159. typedef int (*MWhandler) (IPTR, int);
  160.  
  161. #define get_RM(im)  (im->pc[0])
  162. #define get_GM(im)  (im->pc[1])
  163. #define get_BM(im)  (im->pc[2])
  164.  
  165. #include "gui.h"
  166. #include "mac.h"
  167.  
  168. /* all prototypes */
  169. #include "proto.h"
  170.  
  171. #endif
  172.